from anim_bone import *

pose_driver = anim_pose_driver_datas(
    "G:/UnityProject/KawaiiUnity/KawaiiUnityProj/Assets/ResForAssetBundles/Avatar/KawaiiPhysicsData/KawaiiPoseDriverAsset/聚类Pose-02326-Root_stderr_2.asset"
)

pose_driver_data = pose_driver.data["MonoBehaviour"]["PoseTargetDatas"]

scales = []
for data in pose_driver_data:
    q_left = [
        data["BoneTransforms"][0]["Rotation"]["w"],
        data["BoneTransforms"][0]["Rotation"]["x"],
        data["BoneTransforms"][0]["Rotation"]["y"],
        data["BoneTransforms"][0]["Rotation"]["z"],
    ]
    q_right = [
        data["BoneTransforms"][1]["Rotation"]["w"],
        data["BoneTransforms"][1]["Rotation"]["x"],
        data["BoneTransforms"][1]["Rotation"]["y"],
        data["BoneTransforms"][1]["Rotation"]["z"],
    ]
    sacle_left = anim_transform.scaling(np.array(q_left))
    sacle_right = anim_transform.scaling(np.array(q_right))
    data["Scale"] = (sacle_left + sacle_right) / 2

pose_driver.save()